package com.springbootx.mybatis.mapper;

import com.springbootx.mybatis.config.DataSourceType;
import com.springbootx.mybatis.config.annotations.DataSource;
import com.springbootx.mybatis.pojo.Users;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
 * @author Tony.niu (hystrix0779@yeah.net)
 * @version V1.0
 **/
@Mapper
public interface MasterUsersMapper {
    /**
     * 写入数据
     * @param users 实体
     */
    @DataSource(value = DataSourceType.MASTER)
    @Insert("<script> INSERT INTO users\n" +
            "        (id,user_name,pass_word,phone,email)\n" +
            "        VALUES\n" +
            "        (#{id,jdbcType=INTEGER},#{userName,jdbcType=VARCHAR},#{passWord,jdbcType=VARCHAR},\n" +
            "        #{phone,jdbcType=VARCHAR},#{email,jdbcType=VARCHAR})</script> ")
    void insert (Users users);
    /**
     * 删除数据
     */
    @DataSource(value = DataSourceType.MASTER)
    @Delete("DELETE from users where 1 = 1")
    void delete ();

    @DataSource(value = DataSourceType.MASTER)
    @Update("UPDATE `zw_user`.`users` SET `user_name` = 'salve测试数据1' WHERE `id` = 0 AND `user_name` = Cast('salve测试数据' AS Binary(17)) AND `pass_word` = Cast('salve测试数据' AS Binary(17)) AND `phone` = Cast('salve测试数据' AS Binary(17)) AND `email` = Cast('salve测试数据' AS Binary(17)) AND `create_day` = Cast('2021-04-29 11:07:49' AS Binary(19)) LIMIT 1")
    void update();
}
